<!DOCTYPE HTML>
<html>
<head>
    <title>后台系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!--<link href="../static_pc/assets3/css/bs3/dpl-min.css" rel="stylesheet" type="text/css"/>-->
    <!--<link href="../static_pc/assets3/css/bs3/bui-min.css" rel="stylesheet" type="text/css"/>-->
    <link href="../static_pc/assets/css/dpl-min.css" rel="stylesheet" type="text/css"/>
    <link href="../static_pc/assets/css/bui-min.css" rel="stylesheet" type="text/css"/>
    <link href="../static_pc/assets/css/main.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body>
<div class="header" id="wel">
    <div class="dl-title"><span class="">后台系统</span></div>
    <div v-if="greeting" v-cloak class="dl-log">欢迎您：<span class="dl-log-user">{{ user }}</span>
        <a href="javascript:void(0);" onclick="upd()" title="修改密码" class="dl-log-quit btn-edit">[修改密码]</a>
        <a href="javascript:void(0);" onclick="loginOut()" title="退出系统" class="dl-log-quit">[退出]</a>
    </div>
</div>
<div class="content">
    <div class="dl-main-nav" style="display:none">
        <ul id="J_Nav" class="nav-list ks-clear">
            <li class="nav-item dl-selected"></li>
        </ul>
    </div>
    <ul id="J_NavContent" class="dl-tab-conten">

    </ul>
</div>

<div id="content" class="hide">
    <form id="psd" class="form-horizontal" action="../admin/updPsd" method="post">
        <div class="row">
            <div class="control-group span8">
                <label class="control-label"><s>*</s>旧密码</label>

                <div class="controls">
                    <input name="oldpassword" type="password" data-rules="{required:true}"
                           class="input-normal control-text">
                </div>
            </div>
        </div>
        <div class="row">
            <div class="control-group span8">
                <label class="control-label"><s>*</s>新密码</label>

                <div class="controls">
                    <input id="p1" name="password" type="password" data-rules="{required:true}"
                           class="input-normal control-text">
                </div>
            </div>
        </div>
        <div class="row">
            <div class="control-group span15">
                <label class="control-label"><s>*</s>确认密码</label>

                <div class="controls">
                    <input name="repassword" type="password" data-rules="{required:true,equalTo:'#p1'}"
                           class="input-normal control-text">
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="../static_pc/common/jquery.min-2.1.3.js"></script>
<script type="text/javascript" src="../static_pc/common/jquery.form.js"></script>
<script type="text/javascript" src="../static_pc/layer/layer.js"></script>
<script type="text/javascript" src="../static_pc/assets/js/bui-min.js"></script>
<script type="text/javascript" src="../static_pc/assets/js/config-min.js"></script>
<script type="text/javascript" src="../static_pc/vue2/vue.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        index.detail.init();
    });
    function loginOut() {
        index.detail.loginOut();
    }
    var Overlay = BUI.Overlay,
            Form = BUI.Form;
    //添加 名字为 sid的校验规则
    Form.Rules.add({
        name: 'rep',  //规则名称
        msg: '两次输入不一致',//默认显示的错误信息
        validator: function (value, baseValue, formatMsg) { //验证函数，验证值、基准值、格式化后的错误信息
            if (value && value != $("[name='password']").val()) {
                return formatMsg;
            }
        }
    });

    var form = new Form.Form({
        srcNode: '#psd'
    }).render();

    var dialog = new Overlay.Dialog({
        title: '修改密码',
        width: 350,
        //配置DOM容器的编号
        contentId: 'content',
        success: function () {
            $("#psd").submit();
        }
    });

    function upd() {
        $("[name='oldpassword']").val("");
        $("[name='password']").val("");
        $("[name='repassword']").val("");
        dialog.show();
    }

    $("#psd").ajaxForm({
        //定义返回JSON数据，还包括xml和script格式
        dataType:'json',
        beforeSend: function() {
            //表单提交前做表单验证
            //return check();
            layer.load();
        },
        success: function(data) {
            layer.closeAll('loading');
            if (!data.hasError) {
                BUI.Message.Alert(data.error,function(){
                    dialog.close();
                },'info');
            }else {
                BUI.Message.Alert(data.error,'warning');
            }
        },
        error : function(XMLHttpRequest, textStatus, errorThrown) {
            layer.closeAll('loading');
            BUI.Message.Alert("系统繁忙，请稍后"+XMLHttpRequest.status+","+XMLHttpRequest.readyState+","+textStatus,'warning');
        }
    });

</script>
</body>
</html>